import React from "react";
import { Route } from "react-router-dom";
import Home from "../pages/Home";
import Page404 from "../pages/404";
import { routerData } from "./routes";

function UserRoutes() {
  const renderRouter = (
    item: { path: string; component: React.ReactNode },
    index: number
  ) => {
    return <Route key={index} path={item.path} element={item.component} />;
  };

  return (
    <Route path="home" element={<Home />}>
      {routerData.map(renderRouter)}
      <Route path="*" element={<Page404 />} />
    </Route>
  );
}

export default UserRoutes;
